// 订单状态
export const ORDER_STATUS = {
  PENDING: 'pending',
  PAID: 'paid',
  SHIPPED: 'shipped',
  COMPLETED: 'completed',
  CANCELLED: 'cancelled',
  REFUNDED: 'refunded'
} as const

export type OrderStatus = typeof ORDER_STATUS[keyof typeof ORDER_STATUS]

// 订单状态文本
export const ORDER_STATUS_TEXT = {
  [ORDER_STATUS.PENDING]: '待支付',
  [ORDER_STATUS.PAID]: '已支付',
  [ORDER_STATUS.SHIPPED]: '已发货',
  [ORDER_STATUS.COMPLETED]: '已完成',
  [ORDER_STATUS.CANCELLED]: '已取消',
  [ORDER_STATUS.REFUNDED]: '已退款'
} as const

// 支付状态
export const PAYMENT_STATUS = {
  PENDING: 'pending',
  SUCCESS: 'success',
  FAILED: 'failed',
  REFUNDED: 'refunded'
} as const

export type PaymentStatus = typeof PAYMENT_STATUS[keyof typeof PAYMENT_STATUS]

// 支付状态文本
export const PAYMENT_STATUS_TEXT = {
  [PAYMENT_STATUS.PENDING]: '待支付',
  [PAYMENT_STATUS.SUCCESS]: '支付成功',
  [PAYMENT_STATUS.FAILED]: '支付失败',
  [PAYMENT_STATUS.REFUNDED]: '已退款'
} as const

// 订单标签页类型
export const ORDER_TAB_STATUS = {
  ALL: 'all',
  PENDING: 'pending',
  TO_SHIP: 'to_ship',
  TO_RECEIVE: 'to_receive',
  COMPLETED: 'completed',
  CANCELLED: 'cancelled',
  REFUNDED: 'refunded'
} as const

// 订单标签页配置
export const ORDER_TAB_CONFIG = {
  [ORDER_TAB_STATUS.ALL]: {
    label: '全部订单',
    orderStatus: undefined,
    paymentStatus: undefined
  },
  [ORDER_TAB_STATUS.PENDING]: {
    label: '待支付',
    orderStatus: ORDER_STATUS.PENDING,
    paymentStatus: PAYMENT_STATUS.PENDING
  },
  [ORDER_TAB_STATUS.TO_SHIP]: {
    label: '待发货',
    orderStatus: ORDER_STATUS.PAID,
    paymentStatus: PAYMENT_STATUS.SUCCESS
  },
  [ORDER_TAB_STATUS.TO_RECEIVE]: {
    label: '待收货',
    orderStatus: ORDER_STATUS.SHIPPED,
    paymentStatus: PAYMENT_STATUS.SUCCESS
  },
  [ORDER_TAB_STATUS.COMPLETED]: {
    label: '已完成',
    orderStatus: ORDER_STATUS.COMPLETED,
    paymentStatus: PAYMENT_STATUS.SUCCESS
  },
  [ORDER_TAB_STATUS.CANCELLED]: {
    label: '已取消',
    orderStatus: ORDER_STATUS.CANCELLED,
    paymentStatus: PAYMENT_STATUS.PENDING
  },
  [ORDER_TAB_STATUS.REFUNDED]: {
    label: '退款/售后',
    orderStatus: ORDER_STATUS.COMPLETED,
    paymentStatus: PAYMENT_STATUS.REFUNDED
  }
} as const
